package com.tjn.customGeneric;

import java.util.ArrayList;

/**
 * @author 陶镓妮
 * @version 1.0
 */
@SuppressWarnings("all")
public class CustomMethodGeneric {
    public static void main(String[] args) {
        Car car = new Car();
        car.run("奥迪",1000);
        car.run(1000,"保时捷");//传入什么参数就会确定什么类型

        System.out.println("==========");
        Fish<ArrayList, Integer> fish = new Fish<>();
        fish.swim(new ArrayList(),1000);
    }
}
class Car{
    public <T,R> void run(T t,R r){//自定义泛型方法在普通类中
        System.out.println(t.getClass());
        System.out.println(r.getClass());
    }
}

class Fish<E,T>{
    public void eat(E e){//这个不是泛型方法，它是使用了类声明的泛型
    }
    public <M> void swim (E e,M m){//自定义泛型方法在泛型类中
        System.out.println(e.getClass());
        System.out.println(m.getClass());
    }
}